<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;

class PublicController extends Controller
{

    public function register(Request $request)
    {
        $email = $request->input('email');
        $pass = $request->input('pass');
        $user = User::forceCreate([
            'email' => $email,
            'name' => $email,
            'password' => password_hash($pass, PASSWORD_DEFAULT)
        ]);
        dd($user);
    }

    public function login(Request $request)
    {
        $email = $request->input('email');
        $pass = $request->input('pass');
        $user = User::where('email', $email)->firstOrFail();
        if (password_verify($user->password, $pass)) {
            echo 123;
        } else {
            echo 321;
        }
        dd($user->createToken('tank', ['*'])->plainTextToken);
    }

}
